{% template "admin/header.html" %}
<div class="admin-main layui-anim layui-anim-upbit">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>添加</legend>
    </fieldset>
    <form class="layui-form layui-form-pane" lay-filter="form">
        <div class="layui-form-item">
            <label class="layui-form-label">用户组名</label>
            <div class="layui-input-4">
                <input type="text" name="group_name" autocomplete="off" lay-verify="required" placeholder="用户组名" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                用户名在4到25个字符之间。
            </div>
        </div>


        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="button" class="layui-btn" lay-submit="" lay-filter="submit">提交</button>
                <a href="javascript:window.history.back();" class="layui-btn layui-btn-primary">返回</a>
            </div>
        </div>
    </form>
</div>

{% template "admin/footer.html" %}
<script>
    layui.use(['form', 'layer'], function () {
        var form = layui.form, layer = layui.layer,$= layui.jquery;


        form.on('submit(submit)', function (data) {
            loading =layer.load(1, {shade: [0.1,'#fff']});
            $.post("/admin/group/add", data.field, function (res) {
                layer.close(loading);
                if (res.Code > 0) {
                    layer.msg(res.Msg, {time: 1800, icon: 1}, function () {
                        window.history.back();
                    });
                } else {
                    layer.msg(res.Msg, {time: 1800, icon: 2});
                }
            });
        });

    });
</script>
</body>
</html>
